<?php
class PageCtrl extends ControllerPublic {
    public function OnLoad(){
        $this->SetMenu();
        $this->SetLanguagePicker();
        parent::OnLoad();
    }

    public function Index() {
        $resources = Doctrine_Core::getTable('Page')
            ->createQuery('p')
            ->select("p.title, p.body")
            ->where('p.visibility_id = '.appcode\enum\Visibility::GetByName(appcode\enum\Visibility::V_public).' && p.language = "'.$this->Language.'" and p.id = '.$this->Id)
            ->fetchArray();

        $title = "Page not found";
        $body = "Page not found";

        if(count($resources) != 0){
            $resources = current($resources);
            $title = $resources["title"];
            $body = $resources["body"];
        }

        parent::Title($title);

        $this->Smarty->assign("pagetitle", $title);
        $this->Smarty->assign("pagebody", $body);
    }
}
